﻿using System;
using System.Collections.Generic;
using NUnit.Framework;

namespace CodeContrib.Tests
{
	public class GuardTests
	{
		private const string _parameterName = "test";

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_NegativeDecimal_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			decimal value = -1;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_NegativeFloat_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			float value = -1;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_NegativeInteger_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			var value = -1;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_ZeroDecimal_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			decimal value = 0;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_ZeroFloat_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			float value = 0;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegativeOrZero_With_ZeroInteger_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			var value = 0;

			// Act
			Guard.NotNegativeOrZero(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegative_With_NegativeDecimal_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			decimal value = -1;

			// Act
			Guard.NotNegative(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegative_With_NegativeFloat_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			float value = -1;

			// Act
			Guard.NotNegative(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentOutOfRangeException))]
		public void IsNotNegative_With_NegativeInteger_ShouldThrow_ArgumentOutOfRangeException()
		{
			// Arrange
			var value = -1;

			// Act
			Guard.NotNegative(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_EmptyStringArray_ShouldThrow_ArgumentException()
		{
			// Arrange
			var value = new string[0];

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_EmptyStringList_ShouldThrow_ArgumentException()
		{
			// Arrange
			IList<string> value = new List<string>();

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_Emptytring_ShouldThrow_ArgumentException()
		{
			// Arrange
			var value = string.Empty;

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_NullStringArray_ShouldThrow_ArgumentException()
		{
			// Arrange
			string[] value = null;

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_NullStringList_ShouldThrow_ArgumentException()
		{
			// Arrange
			IList<string> value = null;

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentException))]
		public void IsNotNullOrEmpty_With_NullString_ShouldThrow_ArgumentException()
		{
			// Arrange
			string value = null;

			// Act
			Guard.NotNullOrEmpty(value, _parameterName);
		}

		[Test]
		[ExpectedException(typeof (ArgumentNullException))]
		public void IsNotNull_With_NullObject_ShouldThrow_ArgumentNullException()
		{
			// Arrange
			object value = null;

			// Act
			Guard.NotNull(value, _parameterName);
		}
	}
}